home *** CD-ROM | disk | FTP | other *** search
/ People & Parliament - A …er's Guide to Westminster / People and Parliament - A Stranger's Guide to Westminster (1998)(House of Commons).iso / parl / 8bit80.dir / 00036_Script_36 < prev    next >
Text File  |  1998-03-23  |  2KB  |  45 lines

  1. on circleDrag sNum,sC
  2.   puppetSprite sNum,true
  3.   set rC = (the right of sprite sC - the left of sprite sC)/2
  4.   set rSNum to (the right of sprite sNum - the left of sprite sNum)/2
  5.   set cH to the locH of sprite sC + 1
  6.   set cV to the locV of sprite sC + 1
  7.   set rC to rC - rSNum
  8.   set deltaH to the locH of the clickLoc - the locH of sprite sNum
  9.   set deltaV to the locV of the clickLoc - the locV of sprite sNum
  10.   
  11.   repeat while the mouseDown
  12.     if the mouseH < cH then
  13.       set mH to the mouseH - deltaH
  14.       set mV to the mouseV - deltaV
  15.       set A to mH - cH
  16.       set B to mV - cV
  17.       set r to sqrt(A*A + B*B)
  18.       
  19.       if A <> 0 then
  20.         set grad = float(B)/A
  21.         set constraint = 2.2 -- tan of 130 degrees swing
  22.         if grad <= constraint and grad >= 0 - constraint then
  23.           set angle = atan (grad) + atan (constraint)
  24.           displayYear angle / (atan(constraint)*2) -- return percentage of travel
  25.           set newX = rC/sqrt(1+grad*grad)
  26.           if mH < cH then set newX to 0 - newX
  27.           set newY to Grad*newX
  28.           set the locH of sprite sNum to newX + cH
  29.           set the locV of sprite sNum to newY + cV
  30.         end if
  31.       end if
  32.       updateStage
  33.     end if
  34.   end repeat
  35. end
  36.  
  37. on displayYear percentVal
  38.   global yearList
  39.   set yearList to [1066,1097,1215,1254,1265,1295,1341,1376,1523,1547,1605,1640,1678,1688,1694,1707,1716,1801,1803,1812,1832,1834,1852,1867,1911,1918,1941,1958,1978,1992]
  40.   set yearNum to integer(count(yearList) * percentval)
  41.   if yearNum = 0 then set yearNum =1
  42.   set the text of field "readout" to string(getAt(yearList, yearNum))
  43. end
  44.  
  45.